#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define det(a,b,c) pow(b,2)-4*a*c

//double det(double a, double b, double, c);

double *solve_quad(double, double, double, double);

int main()
{
	double determinant = -1;
	double a,b,c;

	double * result = NULL;
	printf("input:a b c:");
	scanf("%lf %lf %lf", &a, &b, &c);
	determinant = det(a, b, c);
	printf("det:%lf\n", determinant);
	if(determinant >=0)
	{
		result = solve_quad(a, b , c, determinant);
		printf("x1:%lf\n", *result);
		printf("x2:%lf\n", *(result+1));
		free(result);
	}
	else
	{
		printf("No solution\n");
	}
	return 0;
}
/*
double det(double a, double b, double c)
{
	double result = b * b - 4 * a * c;
}
*/

double *solve_quad(double a, double b, double c, double determinant)
{
	double * result_ptr;
	result_ptr = malloc(2 * sizeof(double));
	*result_ptr = (-b + sqrt(determinant))/(2 * a);
	*(result_ptr+1) = (-b - sqrt(determinant))/(2 * a);
	return result_ptr;
}
